namespace Century.Model.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class century : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.ActionModules",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        DisplayName = c.String(),
                        Group = c.String(),
                        RequiredAdministrator = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.ActionModuleRoles",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ActionModuleId = c.Int(nullable: false),
                        RoleName = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ActionModules", t => t.ActionModuleId, cascadeDelete: true)
                .Index(t => t.ActionModuleId);
            
            CreateTable(
                "dbo.SystemConfigurations",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Owner = c.String(),
                        ConfigKey = c.String(),
                        ConfigValue = c.String(),
                        CodeValue = c.String(),
                        ConfigTag = c.Binary(),
                        PossibleValues = c.String(),
                        ValueType = c.String(nullable: false),
                        Description = c.String(),
                        IsEncrypt = c.Boolean(nullable: false),
                        EncryptType = c.String(),
                        ListSeparator = c.String(maxLength: 1),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CharValues",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CharTypeId = c.Int(nullable: false),
                        Description = c.String(),
                        Number = c.Int(),
                        Code = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CharTypes", t => t.CharTypeId, cascadeDelete: true)
                .Index(t => t.CharTypeId);
            
            CreateTable(
                "dbo.CharTypes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        TypeName = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CharValueTranslations",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CharValueId = c.Int(nullable: false),
                        Site = c.String(),
                        OrderInList = c.Int(nullable: false),
                        IsAvailable = c.Boolean(nullable: false),
                        Description = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CharValues", t => t.CharValueId, cascadeDelete: true)
                .Index(t => t.CharValueId);
            
            CreateTable(
                "dbo.TranslationTexts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SiteId = c.Int(nullable: false),
                        TranslationKey = c.String(),
                        TranslationValue = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Sites", t => t.SiteId, cascadeDelete: true)
                .Index(t => t.SiteId);
            
            CreateTable(
                "dbo.Sites",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CountryId = c.Int(nullable: false),
                        LanguageCode = c.String(nullable: false, maxLength: 2),
                        Name = c.String(maxLength: 256),
                        Path = c.String(nullable: false, maxLength: 512),
                        IsDefault = c.Boolean(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                        SiteAnalyticsScript = c.String(),
                        LiveApplicationUrl = c.String(maxLength: 1024),
                        DemoApplicationUrl = c.String(maxLength: 1024),
                        LoginUrl = c.String(maxLength: 1024),
                        SiteAddress = c.String(maxLength: 128),
                        Flag = c.String(maxLength: 10),
                        TwinSiteId = c.Int(),
                        LocalName = c.String(),
                        FlagImageName = c.String(),
                        Culture = c.String(),
                        ContryCode = c.String(maxLength: 2),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Countries", t => t.CountryId, cascadeDelete: true)
                .Index(t => t.CountryId);
            
            CreateTable(
                "dbo.Countries",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(maxLength: 128),
                        Code = c.String(maxLength: 6),
                        IsFSA = c.Boolean(nullable: false),
                        SortOrder = c.Int(nullable: false),
                        ContinentId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Continents", t => t.ContinentId, cascadeDelete: true)
                .Index(t => t.ContinentId);
            
            CreateTable(
                "dbo.Continents",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.UserProfile",
                c => new
                    {
                        UserId = c.Int(nullable: false, identity: true),
                        UserName = c.String(),
                        Email = c.String(),
                        TitleId = c.Int(),
                        FirstName = c.String(maxLength: 64),
                        MiddleName = c.String(maxLength: 64),
                        LastName = c.String(maxLength: 64),
                        CellPhone = c.String(maxLength: 32),
                        HomePhone = c.String(maxLength: 32),
                        WorkPhone = c.String(maxLength: 32),
                        OtherPhone = c.String(maxLength: 32),
                        Fax = c.String(maxLength: 32),
                        HomeAddress = c.String(),
                        WorkAddress = c.String(),
                        DateOfBirth = c.DateTime(),
                        Gender = c.Int(),
                        NationalityId = c.Int(),
                        CountryOfResidenceId = c.Int(),
                    })
                .PrimaryKey(t => t.UserId)
                .ForeignKey("dbo.Titles", t => t.TitleId)
                .ForeignKey("dbo.Countries", t => t.NationalityId)
                .Index(t => t.TitleId)
                .Index(t => t.NationalityId);
            
            CreateTable(
                "dbo.Titles",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Description = c.String(maxLength: 8),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Provinces",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Description = c.String(maxLength: 32),
                        CountryId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Countries", t => t.CountryId, cascadeDelete: true)
                .Index(t => t.CountryId);
            
            CreateTable(
                "dbo.Cities",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Description = c.String(maxLength: 32),
                        ProvinceId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Provinces", t => t.ProvinceId, cascadeDelete: true)
                .Index(t => t.ProvinceId);
            
            CreateTable(
                "dbo.SitePages",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SiteId = c.Int(nullable: false),
                        PageLayoutId = c.Int(),
                        Name = c.String(nullable: false),
                        LocalName = c.String(nullable: false),
                        IsHomePage = c.Boolean(nullable: false),
                        Title = c.String(nullable: false),
                        Keywords = c.String(),
                        Description = c.String(),
                        ParentId = c.Int(),
                        Url = c.String(),
                        Roles = c.String(),
                        NodeOrder = c.Int(nullable: false),
                        ShowInMenu = c.Boolean(nullable: false),
                        ShowInRightMenu = c.Boolean(nullable: false),
                        MenuDescription = c.String(),
                        ImagePath = c.String(),
                        IsPublished = c.Boolean(nullable: false),
                        DraftSourcePageId = c.Int(nullable: false),
                        MenuImagePath = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.PageLayouts", t => t.PageLayoutId)
                .ForeignKey("dbo.Sites", t => t.SiteId, cascadeDelete: true)
                .Index(t => t.PageLayoutId)
                .Index(t => t.SiteId);
            
            CreateTable(
                "dbo.PageLayouts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Path = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.ContentHolders",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PageLayoutId = c.Int(nullable: false),
                        Name = c.String(),
                        Title = c.String(),
                        Description = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.PageLayouts", t => t.PageLayoutId, cascadeDelete: true)
                .Index(t => t.PageLayoutId);
            
            CreateTable(
                "dbo.ContentHolderParts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SitePageId = c.Int(nullable: false),
                        ContentHolderId = c.Int(nullable: false),
                        StaticContentId = c.Int(),
                        DynamicContentId = c.Int(),
                        PartOrder = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ContentHolders", t => t.ContentHolderId, cascadeDelete: true)
                .ForeignKey("dbo.SitePages", t => t.SitePageId, cascadeDelete: true)
                .ForeignKey("dbo.StaticContents", t => t.StaticContentId)
                .ForeignKey("dbo.DynamicContents", t => t.DynamicContentId)
                .Index(t => t.ContentHolderId)
                .Index(t => t.SitePageId)
                .Index(t => t.StaticContentId)
                .Index(t => t.DynamicContentId);
            
            CreateTable(
                "dbo.StaticContents",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Description = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.DynamicContents",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ActionName = c.String(),
                        ControllerName = c.String(),
                        AreaName = c.String(),
                        ContentName = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SitePageParameters",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SitePageId = c.Int(nullable: false),
                        ParamName = c.String(),
                        ParamValue = c.String(),
                        ParamType = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.SitePages", t => t.SitePageId, cascadeDelete: true)
                .Index(t => t.SitePageId);
            
            CreateTable(
                "dbo.Logs",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Date = c.DateTime(nullable: false),
                        Thread = c.String(nullable: false, maxLength: 255),
                        Level = c.String(nullable: false, maxLength: 50),
                        Logger = c.String(nullable: false, maxLength: 255),
                        Message = c.String(nullable: false),
                        Exception = c.String(),
                        ClientIp = c.String(),
                        HostName = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.TranslationTexts", "SiteId", "dbo.Sites");
            DropForeignKey("dbo.SitePageParameters", "SitePageId", "dbo.SitePages");
            DropForeignKey("dbo.SitePages", "SiteId", "dbo.Sites");
            DropForeignKey("dbo.ContentHolderParts", "DynamicContentId", "dbo.DynamicContents");
            DropForeignKey("dbo.ContentHolderParts", "StaticContentId", "dbo.StaticContents");
            DropForeignKey("dbo.ContentHolderParts", "SitePageId", "dbo.SitePages");
            DropForeignKey("dbo.ContentHolderParts", "ContentHolderId", "dbo.ContentHolders");
            DropForeignKey("dbo.ContentHolders", "PageLayoutId", "dbo.PageLayouts");
            DropForeignKey("dbo.SitePages", "PageLayoutId", "dbo.PageLayouts");
            DropForeignKey("dbo.Sites", "CountryId", "dbo.Countries");
            DropForeignKey("dbo.Cities", "ProvinceId", "dbo.Provinces");
            DropForeignKey("dbo.Provinces", "CountryId", "dbo.Countries");
            DropForeignKey("dbo.UserProfile", "NationalityId", "dbo.Countries");
            DropForeignKey("dbo.UserProfile", "TitleId", "dbo.Titles");
            DropForeignKey("dbo.Countries", "ContinentId", "dbo.Continents");
            DropForeignKey("dbo.CharValueTranslations", "CharValueId", "dbo.CharValues");
            DropForeignKey("dbo.CharValues", "CharTypeId", "dbo.CharTypes");
            DropForeignKey("dbo.ActionModuleRoles", "ActionModuleId", "dbo.ActionModules");
            DropIndex("dbo.TranslationTexts", new[] { "SiteId" });
            DropIndex("dbo.SitePageParameters", new[] { "SitePageId" });
            DropIndex("dbo.SitePages", new[] { "SiteId" });
            DropIndex("dbo.ContentHolderParts", new[] { "DynamicContentId" });
            DropIndex("dbo.ContentHolderParts", new[] { "StaticContentId" });
            DropIndex("dbo.ContentHolderParts", new[] { "SitePageId" });
            DropIndex("dbo.ContentHolderParts", new[] { "ContentHolderId" });
            DropIndex("dbo.ContentHolders", new[] { "PageLayoutId" });
            DropIndex("dbo.SitePages", new[] { "PageLayoutId" });
            DropIndex("dbo.Sites", new[] { "CountryId" });
            DropIndex("dbo.Cities", new[] { "ProvinceId" });
            DropIndex("dbo.Provinces", new[] { "CountryId" });
            DropIndex("dbo.UserProfile", new[] { "NationalityId" });
            DropIndex("dbo.UserProfile", new[] { "TitleId" });
            DropIndex("dbo.Countries", new[] { "ContinentId" });
            DropIndex("dbo.CharValueTranslations", new[] { "CharValueId" });
            DropIndex("dbo.CharValues", new[] { "CharTypeId" });
            DropIndex("dbo.ActionModuleRoles", new[] { "ActionModuleId" });
            DropTable("dbo.Logs");
            DropTable("dbo.SitePageParameters");
            DropTable("dbo.DynamicContents");
            DropTable("dbo.StaticContents");
            DropTable("dbo.ContentHolderParts");
            DropTable("dbo.ContentHolders");
            DropTable("dbo.PageLayouts");
            DropTable("dbo.SitePages");
            DropTable("dbo.Cities");
            DropTable("dbo.Provinces");
            DropTable("dbo.Titles");
            DropTable("dbo.UserProfile");
            DropTable("dbo.Continents");
            DropTable("dbo.Countries");
            DropTable("dbo.Sites");
            DropTable("dbo.TranslationTexts");
            DropTable("dbo.CharValueTranslations");
            DropTable("dbo.CharTypes");
            DropTable("dbo.CharValues");
            DropTable("dbo.SystemConfigurations");
            DropTable("dbo.ActionModuleRoles");
            DropTable("dbo.ActionModules");
        }
    }
}
